package lt.pop3client.client;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

public class TestClient {
	private static Logger log = Logger.getLogger(TestClient.class);
	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		//Socket mailSocket = new Socket("pop3.dtiltas.lt",110);
		
		/*BufferedReader serverResponse = new BufferedReader(new InputStreamReader(mailSocket.getInputStream()));
		BufferedWriter serverRequest  = new BufferedWriter(new OutputStreamWriter(mailSocket.getOutputStream()));
		
		serverRequest.write("USER bastys@dtiltas.lt\r\n");
		serverRequest.flush();
		System.out.println(serverResponse.readLine());
		serverRequest.write("PASS bastys@dtiltas.lt\r\n");
		serverRequest.flush();
		System.out.println(serverResponse.readLine());
		serverRequest.write("adsss bastys@dtiltas.lt\r\n");
		serverRequest.flush();
		System.out.println(serverResponse.readLine());
		
		serverRequest.close();
		serverResponse.close();
		mailSocket.close();*/
		BasicConfigurator.configure();
		Client client = new Client("pop3.dtiltas.lt",110);
		try {
			client.connect();
			client.sendCommand("USER bastys@dtiltas.lt");
			client.sendCommand("PASS bmxandfmx");
			client.sendCommand("STAT");
			client.sendCommand("LIST");
			String listElement = "";
			while (!listElement.equals(".")){
				listElement = client.readResponseLine();
				log.debug(listElement);
			}
			client.sendCommand("RETR 30");
			listElement = "";
			while (!listElement.equals(".")){
				listElement = client.readResponseLine();
				log.debug(listElement);
			}
		} catch (Exception e){
			throw e;
		} finally {
			client.disconnect();
		}
		
	}

}
